﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace log4net.ElasticSearch
{
    public class EsWebClient : WebClient
    {
        public int Timeout { get; set; }
        public EsWebClient(int timeOut)
        {
            if (timeOut > 0)
            {
                this.Timeout = timeOut;
            }
            this.Encoding = Encoding.UTF8;
            this.Headers.Add("Content-Type", "text/json");
        }

        protected override WebRequest GetWebRequest(Uri address)
        {
            WebRequest w = base.GetWebRequest(address);
            if (Timeout > 0)
                w.Timeout = Timeout;
            return w; ;
        }
    }
}
